<template>
	<view class="content poRel">
		<view class="wid100 bacFFF">
			<view class="wid100 mar dis mar-top10">
				<view class="wid50" style="border: 1rpx solid #BFBFBF;height: 98rpx;" @click="isTypeClick(0)">
					<view class="wid100 dis disAl disJuC fowe600 foSi40" 
					style="height: 94rpx;" :style="is_type == 0?'color: #37BCC3;':'color: #A3A4A4;'">地址管理</view>
					<view style="height: 4rpx;" :style="is_type == 0?'background-color: #37BCC3;':'background-color: #fff;'"></view>
				</view>
				<view class="wid50" style="border: 1rpx solid #BFBFBF;height: 98rpx;" @click="isTypeClick(1)">
					<view class="wid100 dis disAl disJuC fowe600 foSi40" 
					style="height: 94rpx;" :style="is_type == 1?'color: #37BCC3;':'color: #A3A4A4;'">自提点</view>
					<view style="height: 4rpx;" :style="is_type == 1?'background-color: #37BCC3;':'background-color: #fff;'"></view>
				</view>
			</view>
		</view>
		<scroll-view style="height: 100vh;" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 1rpx;"></view>
			<view v-if="list.length == 0" class="wid90 mar fowe800 foSi35">
				<view style="height: 50rpx;"></view>
				<view class="dis disJuC">
					<image src="../../static/zanwu2.png" style="width: 400rpx;height: 300rpx;"></image>
				</view>
				<view class="textCen mar-top20" style="color: #868686;">暂无数据</view>
			</view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid90 mar borRad20 bacFFF mar-top30" @click="xuanClick(item)"
					style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);padding: 30rpx 0;">
					<view class="wid90 mar">
						<view class="dis disAl ">
							<view class="foSi40 fowe600" style="line-height: 40rpx;">{{item.name}}</view>
							<view class="foSi30 fowe600 mar-left30" style="color: #737373;">{{item.phone}}</view>
						</view>
						<view class="mar-top20 foSi25 overflowHidden" style="color: #737373;">{{item.address+item.content}}</view>
					</view>
				</view>
			</block>
			<view style="height: 140rpx;"></view>
		</scroll-view>
		<view class="poFix wid100 dis disAl disJuC bacFFF" style="height: 124rpx;bottom: 0;">
			<view class="hei80 dis disAl disJuC borRad40 coFFF foSi35 fowe600" @click="tiaozhuan('/pages/wode/addressAdd')"
				style="width: 450rpx;background: #37BCC3;">新增地址</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				last_page: 0,
				page: 1,
				list: [],
				biaoji: 1,
				is_type: 0
			}
		},
		onLoad(option) {
			this.biaoji = option.biaoji
		},
		onShow() {
			
			this.getList()
		},
		methods: {
			isTypeClick(index){
				if(this.is_type != index){
					this.is_type = index
					this.list = [];
					this.getList()
				}
			},
			getList(){
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_address',
					method: 'POST',
					header: {
						'site-id': that.global.site_id,
						"token": uni.getStorageSync('token'),
					},
					data: {
						page: that.page,
						limit: 10,
						is_type: that.is_type,
						gas_station_id:uni.getStorageSync('jiaId')
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.last_page = result.data.last_page
							if(that.page == 1){
								that.list = result.data.data
							}else{
								that.list = that.list.concat(result.data.data)
							}
							
						}
					}
				});
			},
			xuanClick(item){
				uni.$emit('addressClick',item,this.biaoji)
				uni.navigateBack(1)
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				console.log(url)
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		/* #ifdef APP */
		min-height: 100vh;
		/* #endif */
		
		/* #ifdef H5 */
		min-height: calc(100vh - 50px);
		/* #endif */
		
	}
	.xia{
		height: 1rpx;
		background-color: #E1DFDF;
	}
</style>